-module(object).
-export([
    test_obj/0,
    get_value/2,
    get_value_from_list/2
    ]).


test_obj() ->
    {obj,[{"Hello","World"},{"Foo","Bar"}]}.

get_value({obj, List}, InKey) ->
    get_value_(List, InKey);

get_value(Tuple, Inkey) ->
    {error, "Not an Object"}.

get_value_([], InKey) ->
    {error, "Key Not Found"};

get_value_([{Key, Value}|Rest], InKey) ->
    if
        Key =:= InKey -> Value;
        true -> get_value_(Rest, InKey)
    end.

get_value_from_list(List, Key) ->
    get_value_from_list(List, Key, []).

get_value_from_list([], Key, ReturnList) ->
    ReturnList;

get_value_from_list([Head|Rest], Key, ReturnList) ->
    get_value_from_list(Rest, Key, [get_value(Head, Key)| ReturnList]).
